package com.chat.simplechat.controller;

import com.chat.simplechat.entity.LoginUser;
import com.chat.simplechat.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 简聊主页
 * @author wangyabin
 * @date 2022/11/1 16:59
 */
@Controller
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private UserInfoService userInfoService;

    /**
     * 主页
     * @param username
     * @return
     */
    @GetMapping("/index/{username}")
    public String index(@PathVariable("username") String username, Model model){
        LoginUser userInfo = userInfoService.getLoginUser(username);
        model.addAttribute("userInfo",userInfo);
        return "/chat/Home";
    }
    
    @GetMapping("/home")
    public String home(){
        return "/chat/Home";
    }
}
